/* LOCcounter - Decompiled by JCavaj
 * Visit http://www.bysoft.se/sureshot/jcavaj/
 */
package Model;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class LOCcounter
{
    private boolean countComments = true;
    private int minLineSize = 4;
    
    public void setCommentState(boolean bool) {
	countComments = bool;
    }
    
    public void setMinLineSize(int i) {
	if (i > 0)
	    minLineSize = i;
    }
    
    public int getLinesInFile(String string) {
	int i = 0;
	try {
	    BufferedReader bufferedreader
		= new BufferedReader(new FileReader(string));
	    i = getLinesInFile(bufferedreader);
	    bufferedreader.close();
	} catch (IOException ioexception) {
	    System.out.println(ioexception);
	}
	return i;
    }
    
    public int getLinesInFile(BufferedReader bufferedreader)
	throws IOException {
	int i = 0;
	boolean bool = false;
	for (String string = bufferedreader.readLine(); string != null;
	     string = bufferedreader.readLine()) {
	    int i_0_ = 0;
	    int i_1_ = 0;
	    string = string.trim();
	    if (string.startsWith("/*") && !countComments)
		bool = true;
	    if (bool) {
		if (string.indexOf("*/") != -1)
		    bool = false;
	    } else {
		for (/**/; i_1_ < string.length() && i_0_ < minLineSize;
		     i_1_++) {
		    if (string.charAt(i_1_) != ' ')
			i_0_++;
		}
		if (i_0_ == minLineSize) {
		    if (!countComments) {
			if (!string.startsWith("//")
			    && !string.startsWith("--"))
			    i++;
		    } else
			i++;
		}
	    }
	}
	return i;
    }
}
